﻿package com.firewolf.iteratorAndComponent.iterator.self.iterators;

import com.firewolf.iteratorAndComponent.iterator.common.MyMenuItem;

/**
 * 晚餐餐菜单迭代器，实现自己定义的迭代器
 * @author Administrator
 *
 */
public class DinerMenuIterator implements MyIterator{
	private MyMenuItem[] items;
	private int index = 0;
	public DinerMenuIterator(MyMenuItem[] items) {
		this.items = items;
	}
	@Override
	public boolean hasNext() {
		if(index >= items.length || items[index] == null)
			return false;
		else
			return true;
	}

	@Override
	public Object next() {
		MyMenuItem menuItem = items[index];
		index = index+1;
		return menuItem;
	}

}
